#include "stdafx.h"
#include "detail/bmock_in_arg_val.hpp"
#include "bmock_in_out_raw_mem.hpp"

namespace bmock {
	in_arg_val::in_arg_val(const char *const n,const std::string &val)
		:arg_val(n)
		,value_(val)
		,rm_(raw_mem(0,0))
	{}
	in_arg_val::in_arg_val(const char *n,const std::string &val,const raw_mem& rm)
		:arg_val(n)
		,value_(val)
		,rm_(rm)
	{}

	in_arg_val::~in_arg_val() {
	}

	bool in_arg_val::validate(const arg_checker &chk,const std::string &v) const {
		return chk.check_arg(name_,v,value_);
	}

	bool in_arg_val::validate_no_msg(const arg_checker &chk, const std::string &v) const {
		return chk.check_arg_no_msg(name_,v,value_);
	}

	bool in_arg_val::null_supplied() const {
		return(NULL_STR==get_in_value());
	}
	std::string in_arg_val::get_in_value(const arg_checker &chk) const
	{
		if (bmock::in_out_raw_mem_descr_base::exist((void*)rm_.get_ptr())) 
		{
			in_rm rmp_(rm_.get_ptr(),name_,chk);
			return rmp_.rm_.get_value();
		}

		return get_in_value();
	}

	std::string in_arg_val::get_in_value() const {
		return value_;
	}

	void in_arg_val::print(std::ostream &os) const {
		os << "IN(\"";
		print_value(os);
		os << "\")";
	}

	void in_arg_val::print_value(std::ostream &os) const {
		os << get_in_value();
	}
}